package com.sanglh.tutorial.extra;

import android.app.Activity;
import android.content.Intent;
import android.hardware.Camera;
import android.os.Bundle;
import android.widget.FrameLayout;

import com.sanglh.tutorial.R;
import com.sanglh.tutorial.common.util.SettingsUtils;

public class MirrorActivity extends Activity {
	private Camera camera;

	public static void showMirror(Activity context, int requestCode) {
		Intent intent = new Intent(context, MirrorActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
		context.startActivityForResult(intent, requestCode);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_blank_camera);
		camera = SettingsUtils.getFrontCamera();
		CameraPreview preview = new CameraPreview(this, camera);
		((FrameLayout) findViewById(R.id.camera_preview)).addView(preview);
	}
	
	@Override
	protected void onPause() {
		SettingsUtils.releaseCamera(camera);
		finish();
		super.onPause();
	}


}
